PATH
Mac OS 8 and 9 Developer Documentation
>
Interapplication Communication
>
AppleScript for Scripters
>
AppleScript Language Guide
Contents
Figures and Tables
Chapter 1
Introduction
Chapter 2
Overview of AppleScript
Conventions Used in This Guide
What Is AppleScript?
What Makes AppleScript Special?
Who Runs Scripts and Who Writes Them?
What Applications Are Scriptable?
What Can You Do With Scripts?
Automating Activities
Integrating Applications
Customizing Applications and Automating Workflows
How AppleScript Works
Statements
Commands and Objects
Dictionaries
Values and Constants
Expressions
Operations
Variables
Script Objects
Scripting Additions
Dialects
Other Features and Language Elements
Continuation Characters
Comments
Identifiers
Case Sensitivity
Abbreviations
Compiling Scripts With the Script Editor
Debugging Scripts
Chapter 3
Values and Constants
Using Value Class Definitions
Literal Expressions
Properties
Elements
Operators
Commands Handled
Reference Forms
Coercions Supported
Common Value Class Definitions
Boolean
Class
Constant
Data
Date
Integer
List
Number
Real
Record
Reference
String
Styled Text
Text
Unicode Text and International Text
Unit Type Value Classes
AppleScript Unit Types by Category
Working With Unit Type Value Classes
Other Value Classes
File Specification
RGB Color
Styled Clipboard Text
Coercing Values
Constants
Arithmetic Constants
Boolean Constants
Considering and Ignoring Attributes
Date and Time Constants
Miscellaneous Script Constants
Save Option Constants
String Constants
Text Style Constants
Version Constant
Chapter 4
Commands
Types of Commands
Application Commands
AppleScript Commands
Scripting Addition Commands
Target
Name Conflicts
User-Defined Commands
Using Command Definitions
Syntax
Parameters
Result
Examples
Errors
Using Parameters
Coercion of Parameters
Parameters That Specify Locations
Raw Data in Parameters
Using Results
Viewing a Result in the Script Editor's Result Window
Using the Predefined Result Variable
Double Angle Brackets in Results and Scripts
When a Dictionary Is Not Available
When AppleScript Displays Data in Raw Format
Entering Script Information in Raw Format
Sending Raw Apple Events From a Script
Command Definitions
Close
Copy
Count
Delete
Duplicate
Exists
Get
Launch
Make
Move
Open
Print
Quit
Reopen
Run
Save
Set
Chapter 5
Objects and References
Object Class Definitions
Properties
Element Classes
Default Value Class Returned
References
Containers
Complete and Partial References
Reference Forms
Arbitrary Element
Every Element
Filter
ID
Index
Middle Element
Name
Property
Range
Relative
Using the Filter Reference Form
References to Files and Applications
References to Files
Specifying a File by Name or Pathname
Specifying a File by Reference
Specifying a File by Alias
Differences Between Files and Aliases
Specifying a File by File Specification
References to Applications
References to Local Applications
References to Remote Applications
Chapter 6
Expressions
Results of Expressions
Variables
Creating Variables
Using Variables
The A Reference To Operator
Data Sharing
Scope of Variables
Predefined Variables
Script Properties
Defining Script Properties
Using Script Properties
Scope of Script Properties
AppleScript Properties
Reference Expressions
Operations
Operators That Handle Operands of Various Classes
Equal, Is Not Equal To
Greater Than, Less Than
Starts With, Ends With
Contains, Is Contained By
Concatenation
Operator Precedence
Date-Time Arithmetic
Working With Dates at Century Boundaries
Chapter 7
Control Statements
Characteristics of Control Statements
Debugging Control Statements
Tell Statements
Nested Tell Statements
Using
it.
me.
and
my
in Tell Statements
Tell (Simple Statement)
Tell (Compound Statement)
If Statements
If (Simple Statement)
If (Compound Statement)
Repeat Statements
Repeat (forever)
Repeat (number) Times
Repeat While
Repeat Until
Repeat With (loopVariable) From (startValue) To (stopValue)
Repeat With (loopVariable) In (list)
Exit
Try Statements
Kinds of Errors
How Errors Are Handled
Writing a Try Statement
Try
Signaling Errors in Scripts
Error
Considering and Ignoring Statements
Considering/Ignoring
With Timeout Statements
With Timeout
With Transaction Statements
With Transaction
Chapter 8
Handlers
Script Applications
About Subroutines
The Return Statement
A Sample Subroutine
Types of Subroutines
Scope of Subroutine Calls in Tell Statements
Checking the Classes of Subroutine Parameters
Recursive Subroutines
Saving and Loading Libraries of Subroutines
Defining and Calling Subroutines
Subroutines With Labeled Parameters
Defining a Subroutine With Labeled Parameters
Calling a Subroutine With Labeled Parameters
Examples of Subroutines With Labeled Parameters
Subroutines With Positional Parameters
Defining a Subroutine With Positional Parameters
Calling a Subroutine With Positional Parameters
Examples of Subroutines With Positional Parameters
Command Handlers
Command Handler Syntax
Command Handlers for Application Objects
Command Handlers for Script Applications
Run Handlers
Open Handlers
Handlers for Stay-Open Script Applications
Idle Handlers 307
Quit Handlers 308
Interrupting a Script Application's Handlers 309
Calling a Script Application From a Script
Scope of Script Variables and Properties
Declaring Variables and Properties
Scope of Properties and Variables Declared at the Top Level of a Script
Scope of Properties and Variables Declared in a Script Object
Scope of Variables Declared in a Handler
Chapter 9
Script Objects
About Script Objects
Defining Script Objects
Sending Commands to Script Objects
Initializing Script Objects
Inheritance and Delegation
Defining Inheritance
How Inheritance Works
The Continue Statement
Using Continue Statements to Pass Commands to Applications
The Parent Property and the Current Application
Using the Copy and Set Commands With Script Objects
Appendix A
The Language at a Glance
Common Scripting Tasks
Constants
Predefined Variables
Commands
Coercions
References
Operators
Control Statements
Handlers
Script Objects
Variable and Property Assignments and Declarations
Placeholders
Error Numbers and Error Messages
Operating System Errors
Apple Event Errors
Application Scripting Errors
AppleScript Errors
Appendix B
Document Revision History
Glossary
© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)